﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using SaaS.Model.Enums.Systems;
using Web.System.Services.Systems;


namespace Web.System.Controllers.Systems
{
    [Route("api/system/[controller]/[action]")]
    [ApiController]
    public class SettingController : SystemControllerBase
    {
        private readonly SettingAppService _settingAppService;
        public SettingController(SettingAppService settingAppService)
        {
            _settingAppService = settingAppService;
        }
        /// <summary>
        /// 获取设置页面数据
        /// </summary>
        /// <returns></returns>
        [HttpGet]
        public ActionResult Info()
        {
            return Ok(_settingAppService.GetSettings());
        }
        /// <summary>
        /// 保存配置信息
        /// </summary>
        /// <param name="type"></param>
        /// <param name="value"></param>
        /// <returns></returns>
        [HttpPost]
        public ActionResult Save([FromForm]SettingType type, [FromForm]string value)
        {
            return Ok(_settingAppService.SaveSetting(type, value));
        }
    }
}